﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.8.2.min.js?cdv=1" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.8.24.min.js?cdv=1" type="text/javascript"></script>
<link href="../../Content/Styles/button.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

    $(document).ready(function () {
        $(".dtp").datepicker({
            changeYear: true,
            changeMonth: true,
            dateFormat: 'yy/mm',
            onClose: function () {
                var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                $(this).datepicker('setDate', new Date(iYear, iMonth, 1));
            },
        });
        $(".dtpYear").datepicker({
            changeYear: true,
            dateFormat: 'yy',
            onClose: function () {
                var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                $(this).datepicker('setDate', new Date(iYear, 1));
            },
        });
    });

    function GenericTopUserInNewWin() {
        var oParam = { "txtYearFrom": "", "txtYearTo": "" };
        oParam.txtYearFrom = $("#txtYearFrom").val();
        oParam.txtYearTo = $("#txtYearTo").val();

        var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
        var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();

        if(oParam.txtYearFrom > oParam.txtYearTo)
        {
            $('#errorDate').css('display', 'block');
            $('#errorDate').focus();
        }
        else
        {
        $.ajax({
            url: '../../Report/ProcessTopPostUserNewWin',
            data: JSON.stringify(oParam),
            type: 'POST',
            contentType: 'application/json;',
            dataType: 'json',
            success: function (respone) {
                if (respone == true) {
                    $('#errorMessage').css('display', 'none');
                    $('#errorDate').css('display', 'none');
                    window.open("../GenericReport/ShowGenericTopPostUserRpt", 'mywindow', 'fullscreen=yes, scrollbars=auto');
                }
                else {
                    $('#errorDate').css('display', 'none');
                    $('#errorMessage').css('display', 'block');
                    $('#errorMessage').focus();
                }
            }
        });
        }
    }

    function GenericTopRegionInNewWin() {
        var oParam = { "txtYearFrom": "", "txtYearTo": "" };
        oParam.txtYearFrom = $("#txtYearFrom").val();
        oParam.txtYearTo = $("#txtYearTo").val();
        if(oParam.txtYearFrom > oParam.txtYearTo)
        {
            $('#errorDate').css('display', 'block');
            $('#errorDate').focus();
        }
        else
        {
        $.ajax({
            url: '../../Report/ProcessTopRegionNewWin',
            data: JSON.stringify(oParam),
            type: 'POST',
            contentType: 'application/json;',
            dataType: 'json',
            success: function (respone) {
                if (respone == true) {
                    $('#errorMessage').css('display', 'none');
                    $('#errorDate').css('display', 'none');
                    window.open("../GenericReport/ShowGenericTopRegionRpt", 'mywindow', 'fullscreen=yes, scrollbars=auto');
                }
                else {
                    $('#errorDate').css('display', 'none');
                    $('#errorMessage').css('display', 'block');
                    $('#errorMessage').focus();
                }
            }
        });
        }
    }

    function GenericTopUserInMonthsNewWin() {
        var oParam = { "txtYear": ""};
        oParam.txtYear = $("#txtYear").val();
        $.ajax({
            url: '../../Report/ProcessTopUserInMonthsNewWin',
            data: JSON.stringify(oParam),
            type: 'POST',
            contentType: 'application/json;',
            dataType: 'json',
            success: function (respone) {
                if (respone == true) {
                    $('#errorMessage').css('display', 'none');
                    window.open("../GenericReport/ShowGenericTopUserInMonthsRpt", 'mywindow', 'fullscreen=yes, scrollbars=auto');
                }
                else {
                    $('#errorDate').css('display', 'none');
                    $('#errorMessage').css('display', 'block');
                    $('#errorMessage').focus();
                }
            }
        });
    }
</script>
<style>
    .notify
    {
        width: auto;
        height: 20px;
        color: white;
        padding: 5px;
        margin-top: -5px;
        border-radius: 5px;
    }
    
    .ui-datepicker-calendar
    {
        display: none;
    }
    .dtpYear .ui-datepicker-month
    {
        display: none;
    }
    #export
    {
        color: #5b0f32;
        cursor: pointer;
    }
    label
    {
        margin-right: 30px;
        color: #107E79;
        font-weight: bold;
    }
</style>
<h2 style="margin-left: 420px; color: #39A396; margin-top: 10px;">
    Report Management</h2>
@using (Html.BeginForm("ProcessTopPostUser", "Report"))
{
    string times = DateTime.Now.Year.ToString() + '/' + DateTime.Now.Month.ToString();   
    <div id="generalinfo" class="infobox" style="position: relative; height: 200px">
        <div style="margin-top: 30px;">
            <div style="float: left">
                <label style="display: inline">
                    From</label>
                <input type="text" id="txtYearFrom" name="txtYearFrom" value="@times" class="dtp" readonly />
            </div>
            <div style="margin-left: 100px; float: left;">
                <label style="display: inline">
                    To</label>
                <input type="text" id="txtYearTo" name="txtYearTo" value="@times" class="dtp" readonly/><br />
            </div>
        </div>
        <div>
            <div style="clear: both; margin-left: 150px; margin-top: 60px; position: absolute">
                <div>
                    <input type="button" class="small button green" style="background-color: #30B19C;
                        font-size: 14px;" value="Top 5 Region has the most post " onclick="GenericTopRegionInNewWin()" /></div>
                <div>
                    <input type="button" class="small button green" value="Top 5 User create the most Post"
                        style="background-color: #30B19C; font-size: 14px;" onclick="GenericTopUserInNewWin()" /></div>
            </div>
        </div>
        <div style="border-left: 5px solid #333; height: 218px; float: left; left: 570px;
            position: absolute;">
            <div style="">
                <div>
                    <label style="display: inline; margin-left: 100px;">
                        Year</label>
                    <input type="text" id="txtYear" name="txtYear" value="@DateTime.Now.Year" class="dtpYear" readonly/>
                </div>
            </div>
            <div style="clear: both">
                <div>
                    <input type="button" class="small button green" style="background-color: #30B19C;
                        font-size: 14px; width: 247px; text-align: left; margin-left: 100px; margin-top: 20px"
                        value="List User Register in Month " onclick="GenericTopUserInMonthsNewWin()" /></div>
            </div>
        </div>
        <span class="notify" id="errorMessage" style="display: none; background-color: #B22626;
            width: 990px; margin-top: 170px; position: absolute;">
            <h3 style="color: White; text-align: center;">
                Data does not exist...</h3>
        </span><span class="notify" id="errorDate" style="display: none; background-color: #B22626;
            width: 990px; margin-top: 170px; position: absolute;">
            <h3 style="color: White; text-align: center;">
                Please select : Date From < Date To
            </h3>
        </span>
    </div>
}